#!/usr/bin/env python
# coding=utf-8

import unittest
import time
from utility import base

class GradeHomeTests(base.BaseTests):
    def test_goto_grade_reading(self):
        #登出
        self.logout()
        #登录
        self.login()
        time.sleep(0.5)
        self.tap_tab_index(2)

        time.sleep(0.5)

        my_less_tab = self.driver.find_element_by_xpath(u'//XCUIElementTypeButton[@name="我的课程"]')
        self.assertIsNotNone(my_less_tab, u'顶部应该存在一个[我的课程]按钮')
        my_less_tab.click()

        time.sleep(0.25)

        booker_cell = self.driver.find_element_by_xpath(u'//*[@name="布克阅读"]/..')
        if booker_cell: booker_cell.click()

    def test_goto_grade_reading1(self):
        #校验是否进入已付费用户首页
        entry_class = self.driver.find_element_by_xpath(u'//XCUIElementTypeButton[@name="进入课程"]').text
        self.assertEqual(entry_class, u'进入课程', '没有找到进入课程页面 进入失败')
        self.driver.save_screenshot("/Users/fisher/workspace/codes/QA/testimg/已付费用户首页.png")
        print ('进入已付费老用户页面成功')


if __name__ == '__main__':
    test_suite = unittest.TestLoader().loadTestsFromTestCase(GradeHomeTests)
    unittest.TextTestRunner().run(test_suite)